<%@ page language="java"  pageEncoding="utf-8" contentType="text/html; charset=utf-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>增加菜单</title>
     <% 
           String  id=request.getParameter("id");
         %>  
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<LINK href="resource/css/admin.css" type="text/css" rel="stylesheet">
	<link rel="stylesheet" type="text/css" href="scripts/extjs/resources/css/ext-all.css" />   
	<script type="text/javascript" src="scripts/extjs/adapter/ext/ext-base.js"></script> 
	<script type="text/javascript" src="scripts/extjs/ext-all.js"></script>
	
	<script type="text/javascript" >
	    var idvalue="<%=id%>";
	    var  basePath="<%=basePath%>";
	   Ext.onReady(function (){
     var formPanel= new Ext.form.FormPanel({
       renderTo:'addMenu',
       frame : true,
       height : 200,
       width : 300,
       url:basePath+"/tree/addMenu.shtml",
       margins:'3 0 3 3',
       cmargins:'3 3 3 3',
       bodyStyle:'padding:5px 5px 0',
      layout : 'form',
      labelWidth :65,
      labelAlign:"right",
      defaultType:"textfield",
      items:[
      { fieldLabel : '菜单名',
         name:"menuName",
         allowBlank:false,
         minLength : 2,
         minLengthText : "长度不能小于2个字符",
         maxLength : 10,
         maxLengthText : "长度超过了10个字符"
         
       },
        { fieldLabel : '菜单路径',
         name:"menuUrl",
         allowBlank:false 
       },
        { fieldLabel : '菜单说明',
          width:200,
         name:"menuDescribe"
         
       },{
           hidden:true,
           hideLabel:true,
           value:idvalue,
          fieldLabel : '父菜单id',
          width:200,
          name:"id"
       }
      
      ],
     buttons: [{
            text: '提交',
            handler: function(){
                if(formPanel.form.isValid()) {
                   
                   formPanel.getForm().submit({
				waitMsg : '正在处理，请稍等...',
				reset : true,
				failure : function(form, action) {
					Ext.MessageBox.hide();
					Ext.Msg.show({
						title : '错误',
						msg : '<span style="text-align:center;width:250px;margin:5 0 5 0;">'
								+ action.result.msg + '</span>',
						buttons : Ext.MessageBox.OK,
						icon : Ext.MessageBox.WARNING
					});
				},
				success : function(form, action) {
				      
					Ext.MessageBox.hide();
					Ext.Msg.show({
						title : '成功',
						msg : '<span style="text-align:center;width:250px;margin:5 0 5 0;">'
								+ action.result.msg+ '</span>',
						buttons : Ext.MessageBox.OK,
						icon : Ext.MessageBox.INFO
					});
					top[1].location.reload();
				},
				method : 'POST'
			});

                   
                }
            }
        }, {
            text: '重置',
            handler: function() {
               
                formPanel.form.reset();
            }
        }]
       
       }
      
      )

});

	   
	</script>  
  </head>
       
  <body>
       <div align="center" id="addMenu" >
       
      </div>
  </body>
</html>
